import DxFormItem from './DxFormItem';
import useForm, { FieldItem } from './useForm';

export type DxFormProps = {
  fields: FieldItem[];
  model?: Record<string, any>;
};

const DxForm: React.FC<DxFormProps> = ({ fields, model }) => {
  const id = useForm(model);
  console.log('id', id);
  return (
    <div>
      {fields.map((field) => (
        <DxFormItem field={field} key={field.prop} id={id} path={[field.prop]} />
      ))}
    </div>
  );
};

export default DxForm;
